package main.java.LeetCode.ClassicalAlgorithm.Queue;

import main.java.LeetCode.ClassicalAlgorithm.Queue.Impl.ArrayRingBuffer;

public class Main {
    public static void main(String[] args) throws InterruptedException {

        RingBuffer<Integer> ringBuffer = new ArrayRingBuffer<>(8);

        Thread product =
                new Thread(
                        () -> {
                            for (int i = 0; i < 100; i++) {
                                ringBuffer.offer(i);
                            }
                        });

        Thread consumer =
                new Thread(
                        () -> {
                            while (true) {
                                Integer num = ringBuffer.take();
                                System.out.println(num);
                            }
                        });

        product.start();
        consumer.start();
    }
}
